<?php
/**
 * The administration portal
 * 
 * This page allows the user to access the admin interface for the entire site and twiddle
 * with some of the settings including registry/config values, updates and user accounts
 * @author James Ravenscroft
 * @license LGPL
 * @package Edify
 */

include('login.php');
$prefix = $database_prefix;
//Start database connection
$dbh = new dbal("$database_protocol://$database_username:$database_password@$database_host/$database_database");
$dbh->setCacheDir("../cache"); 

//begin templating
$smarty = new Smarty;
$smarty->compile_dir = "../templates_c";
$smarty->template_dir = "../templates";
$smarty->cache_dir = "../cache";
$dbh->compile("SELECT * FROM {$prefix}_registry WHERE cluster LIKE :group ORDER BY cluster");
$r = $dbh->query(array('group' => '%.admin.%.indexLink'));

$location = "../";

while($row = $r->getNext())
{
	if($row['key'] == 'admin_title')
		$array[$row['cluster']]['text'] = $row['value'];
	elseif($row['key'] == 'admin_interface')
		$array[$row['cluster']]['url'] = $location.$row['value'];
}

foreach($array as $key=>$el)
{
	$link[] = $el;
}

$smarty->assign('link', $link);

$smarty->assign('pageTitle',$pageContent);
$smarty->assign('pageContent', "Welcome to the edify admin interface.");
$smarty->display('admin/index.tpl');
?>